package com.lianqi.emcpframework.data.masker.stratgey;
import com.lianqi.emcpframework.data.masker.annotation.MaskData;
import com.lianqi.emcpframework.utils.StringUtils;


/**
 * @program emcp-framework
 * @ClassName PasswordStrategy
 * @description: 电子邮箱脱敏策略实现类
 * @author: sky
 * @create: 2019/05/26 19:29
 */
public class PasswordStrategy implements DataMaskStrategy<String> {


    @Override
    public int defaultMaskLeft() {
        return 0;
    }

    @Override
    public int defaultMaskRight() {
        return 0;
    }

    @Override
    public String maskValue(Object value, MaskData maskData) {
        if (StringUtils.isNullOrEmpty(value)) {
            return null;
        }
        String pwd = org.apache.commons.lang3.StringUtils.left(value.toString(), defaultMaskLeft());
        return org.apache.commons.lang3.StringUtils.rightPad(pwd, value.toString().length(), "*");
    }

}
